package cn.shuto.liferay.plugin.echarts.line.action;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletPreferences;

import com.liferay.portal.kernel.portlet.DefaultConfigurationAction;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;

public class ConfigurationActionImpl extends DefaultConfigurationAction{

	@Override
	public void processAction(PortletConfig portletConfig,
			ActionRequest actionRequest, ActionResponse actionResponse)
			throws Exception {
		PortletPreferences prefs = actionRequest.getPreferences();
		
		String chart_series_indexes_param = ParamUtil.getString(actionRequest, "chart_series_indexes");
		
		if (Validator.isNotNull(chart_series_indexes_param)) {
			prefs.setValue("chart_series_indexes", chart_series_indexes_param);
			int[] chart_series_indexes = StringUtil.split(chart_series_indexes_param, 0);
			for (int chart_series_index : chart_series_indexes) {
				String chart_series_name = ParamUtil.getString(actionRequest, "chart_series_name"+chart_series_index);
				prefs.setValue("chart_series_name"+chart_series_index,chart_series_name);
			}
		}
		super.processAction(portletConfig, actionRequest, actionResponse);
	}
}
